/** 
 * 用户相关请求模块
 */

import request from '@/utils/request'
import qs from 'qs'

interface User {
  phone: string
  password: string
}

interface UserPages {
  "currentPage": number,
  "pageSize": number,
  "phone": number | string,
  "userId"?: number,
  "startCreateTime": string,
  "endCreateTime": string
}

export const login = (data: User) => {
  return request({
    method: 'POST',
    url: '/front/user/login',
    // headers: { 'content-type': 'application/x-www-form-urlencoded' },
    data: qs.stringify(data), // axios 默认发送的是 application/json 格式的数据
  });
}

export const getUserInfo = () => {
  return request({
    method: 'GET',
    url: '/front/user/getInfo',
  });
}

/** 分页查询用户信息 */
export const getUserPages = (data: UserPages) => {
  return request({
    method: 'POST',
    url: '/boss/user/getUserPages',
    data,
  });
}

/** 封禁用户 */
export const ForbidUser = (userId: number) => {
  return request({
    method: 'GET',
    url: '/boss/user/forbidUser',
    params: {
      userId
    },
  });
}